home *** CD-ROM | disk | FTP | other *** search
/ Level 2005 Christmas (DVD) / Level_2005-XMAS_134_DVD_Knightshift.iso / Demos / Ski Racing 2006 / setup1.cab / DataCommonShadersDX8Dot3BumpMap.vsh < prev    next >
Encoding:
Text File  |  2005-11-03  |  1.5 KB  |  51 lines

  1. ;A diffuse bump map effect with one directional and one ambient light
  2. ; Packing definition
  3. ;
  4. ; v0 = position
  5. ; v1 = normal
  6. ; v2 = texture coords
  7. ; v3 = tangent
  8. ; v4 = binormal
  9.  
  10. ;Constant map from the NSF.  
  11. ;
  12. ;WorldViewProjTranspose  0  0
  13. ;InvWorldTranspose       4  0
  14. ;DirLight1Direction      8  1
  15. ;AmbLightColor           9  1   
  16. ;MaterialAmbient         10  0
  17. ;MaterialDiffuse         11  0
  18.  
  19. vs.1.1
  20.  
  21. ; Output transformed vertex into device coordinates.
  22. m4x4 oPos, v0, c0
  23.  
  24. ; Output texture coordinates.
  25. mov  oT0.xy, v2      
  26. mov  oT1.xy, v2      
  27.  
  28. ; Find light vector in object space
  29. mov r5, c8                   ;Get the light direction in world space.
  30. m3x3 r4, r5, c4              ;Transform to object space with inverse world mat
  31.  
  32. ; Normalize light vector.
  33. dp3 r3.x, r4, r4
  34. rsq r2.x, r3.x
  35. mul r0, r4.xyz, r2.xxx
  36.  
  37. ;Transform the light vector into tangent space so we can use in the pixel
  38. ;shader.
  39. dp3 r2.x, r0, v3             ;Tangent
  40. dp3 r2.y, r0, v4             ;Binormal
  41. dp3 r2.z, r0, v1             ;Normal
  42. mad oT2.xyz, r2, c12, c12    ;Scale and bias since texcoord in the pixel shader
  43.                              ;expects a range of 0 to 1.
  44.  
  45. ;Ambient Lighting - rest will be done in ps
  46. mov r1, c10                  ;Move in the ambient material so we can multiply
  47. mul oD0, r1, c9              ;Modulate the ambient light by material
  48. mov oD1, c11                 ;Place the diffuse material in oD1 for use in 
  49.                              ;the pixel shader.
  50.  
  51.